home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Utilities / Calc / lib / nextprim.cal < prev    next >
Encoding:
Text File  |  1992-02-24  |  450 b   |  22 lines  |  [TEXT/????]

  1. /*
  2.  * Copyright (c) 1992 David I. Bell
  3.  * Permission is granted to use, distribute, or modify this source,
  4.  * provided that this copyright notice remains intact.
  5.  *
  6.  * Function to find the next prime (probably).
  7.  */
  8.  
  9. define nextprime(n, tries)
  10. {
  11.     if (isnull(tries))
  12.         tries = 20;
  13.     if (iseven(n))
  14.         n++;
  15.     while (ptest(n, tries) == 0)
  16.         n += 2;
  17.     return n;
  18. }
  19.  
  20. global lib_debug;
  21. if (!isnum(lib_debug) || lib_debug>0) print "nextprime(n, tries) defined";
  22.